package com.juc.scheduledExecutorService.scheduledExecutorService2;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

public class Run {

	//使用Runnable接口进行无返回值的计划任务实现
	public static void main(String[] args) {
		
		List<Runnable> runnableList = new ArrayList<Runnable>();
		runnableList.add(new MyRunnableA());
		runnableList.add(new MyRunnableB());
		ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
		System.out.println("   X " + System.currentTimeMillis());
		executorService.schedule(runnableList.get(0), 0L, TimeUnit.SECONDS);
		executorService.schedule(runnableList.get(1), 0L, TimeUnit.SECONDS);
		System.out.println("   Y " + System.currentTimeMillis());
	}
}
